package com.ruoyi.qsng.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.SnowFlakeUtil;
import com.ruoyi.qsng.domain.KCourseCollect;
import com.ruoyi.qsng.mapper.KCourseCollectMapper;
import com.ruoyi.qsng.service.IKCourseCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 课程收藏Service业务层处理
 *
 * @author kanglou
 * @date 2023-06-07
 */
@Service
public class KCourseCollectServiceImpl implements IKCourseCollectService {
    @Autowired
    private KCourseCollectMapper kCourseCollectMapper;

    /**
     * 查询课程收藏
     *
     * @param id 课程收藏主键
     * @return 课程收藏
     */
    @Override
    public KCourseCollect selectKCourseCollectById(String id) {
        return kCourseCollectMapper.selectKCourseCollectById(id);
    }

    /**
     * 查询课程收藏列表
     *
     * @param kCourseCollect 课程收藏
     * @return 课程收藏
     */
    @Override
    public List<KCourseCollect> selectKCourseCollectList(KCourseCollect kCourseCollect) {
        return kCourseCollectMapper.selectKCourseCollectList(kCourseCollect);
    }

    /**
     * 查询课程收藏列表
     *
     * @param kCourseCollect 课程收藏
     * @return 课程收藏集合
     */
    @Override
    public List<KCourseCollect> selectKCourseCollectDataList(KCourseCollect kCourseCollect) {
        return kCourseCollectMapper.selectKCourseCollectDataList(kCourseCollect);
    }

    /**
     * 新增课程收藏
     *
     * @param kCourseCollect 课程收藏
     * @return 结果
     */
    @Override
    public int insertKCourseCollect(KCourseCollect kCourseCollect) {
        kCourseCollect.setId(SnowFlakeUtil.getNextId());
        kCourseCollect.setCreateTime(DateUtils.getNowDate());
        return kCourseCollectMapper.insertKCourseCollect(kCourseCollect);
    }

    /**
     * 修改课程收藏
     *
     * @param kCourseCollect 课程收藏
     * @return 结果
     */
    @Override
    public int updateKCourseCollect(KCourseCollect kCourseCollect) {
        kCourseCollect.setUpdateTime(DateUtils.getNowDate());
        return kCourseCollectMapper.updateKCourseCollect(kCourseCollect);
    }

    /**
     * 批量删除课程收藏
     *
     * @param ids 需要删除的课程收藏主键
     * @return 结果
     */
    @Override
    public int deleteKCourseCollectByIds(String[] ids) {
        return kCourseCollectMapper.deleteKCourseCollectByIds(ids);
    }

    /**
     * 删除课程收藏信息
     *
     * @param id 课程收藏主键
     * @return 结果
     */
    @Override
    public int deleteKCourseCollectById(String id) {
        return kCourseCollectMapper.deleteKCourseCollectById(id);
    }
}
